-- @owner: @zhanghuan96
-- @date: 2024/10/9
-- @testpoint: ascii()函数作为对象名的测试
@conn PrimaryDbBmode;

@connect PrimaryDbBmode;
--step1:作为列名 expect:成功
drop table if exists ascii_test cascade;
create table ascii_test(ascii text);
insert into ascii_test values('0');

--step2:作为索引名 expect:成功
create index on ascii_test(ascii);

--step3:作为表名 expect:成功
drop table if exists ascii cascade;
create table ascii(ascii text);
drop table if exists ascii cascade;

--step4:作为数据库名 expect:成功
drop database if exists ascii;
create database ascii;
drop database ascii;

--step5:作为外部数据源名 expect:成功
drop data source if exists ascii;
create data source ascii;
drop data source ascii;

--step6:作为自定义函数名 expect:成功
drop function if exists ascii(int);
create or replace function ascii(c1 int)
returns int
as  $$
begin
    return c1;
end;
$$language plpgsql;
/
drop function if exists ascii(int);

--step7:作为存储过程名 expect:成功
drop table if exists t_ascii_0019;
create table t_ascii_0019(c1 text);
CREATE OR REPLACE PROCEDURE ascii(P1 IN int) AS
BEGIN
insert into t_ascii_0019 values ('00001');
raise info '测试ascii作为存储过程名';
END;
/
drop procedure if exists ascii(int);

--step8:作为角色名 expect:成功
drop role if exists ascii;
create role ascii with password 'gauss@123' valid until '2001-12-12';
drop role ascii;

--step9:作为用户组名 expect:成功
drop group if exists ascii;
create group ascii with password 'gauss@123';
drop group ascii;

--step10:作为模式名 expect:成功
drop schema if exists ascii;
create schema ascii;
drop schema ascii;

--step11:作为序列名 expect:成功
create sequence public.ascii start 100 cache 50;
drop sequence public.ascii;

--step12:作为用户名 expect:成功
drop user if exists ascii;
CREATE USER ascii PASSWORD 'Bigdata@123';
drop user ascii;

--step13:作为游标名 expect:成功
drop table if exists ascii_test cascade;
create table ascii_test(cid int,fid int);
start transaction;
cursor ascii for select * from ascii_test order by 1;
close ascii;
end;

--step14:清理环境 expect:成功
drop table if exists ascii_test cascade;
drop table if exists ascii cascade;
drop table if exists t_ascii_0019;
